package ua.com.alus.resvac.crm.domen.entities;

import ua.com.alus.resvac.crm.domen.prototype.CitizenType;
import ua.com.alus.resvac.crm.domen.prototype.SexType;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.List;

/**
 * Resume entity
 */
@Entity
@Table(name = "RESUME")
@NamedQueries(
        {
                @NamedQuery(name = Resume.SELECT_RESUME_BY_ACC_UUID, query = "select r from Resume r where accountUUID=:accountUuid")
        }
)
public class Resume extends BaseEntity implements Serializable {

    public static final String SELECT_RESUME_BY_ACC_UUID = "ua.com.alus.resvac.crm.domen.entities.Resume.selectResumeByUuid";

    @Column(name = "FK_ACCOUNT_UUID", insertable = false, updatable = false)
    private String accountUUID;

    @Column(name = "YEAR")
    private Integer year;

    @Column(name = "SEX")
    @Enumerated(value = EnumType.STRING)
    private SexType sex;

    @Column(name = "FK_CITY_ID")
    private Integer fkCityId;

    @Column(name = "FK_REGION_ID")
    private Integer fkRegionId;

    @Column(name = "MOVE")
    private Boolean move;

    @Column(name = "CITIZENSHIP")
    @Enumerated(value = EnumType.STRING)
    private CitizenType citizenship;

    @Column(name = "POSITION")
    private String position;

    @Column(name = "START_IN_LIFE")
    private Boolean startInLife;

    @Column(name = "SALARY")
    private String salary;

    @Column(name = "PHONE")
    private String phone;

    @Column(name = "FK_PROF_AREA_UUID")
    private String fkProfAreaUuid;

    @ManyToOne
    @JoinColumn(name = "FK_ACCOUNT_UUID", referencedColumnName = "PK_UUID")
    private Account account;

    @OneToMany(mappedBy = "resume", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<ResumeFile> resumeFiles;

    @OneToOne
    @JoinColumn(name = "FK_PROF_AREA_UUID", referencedColumnName = "PK_UUID", insertable = false, updatable = false)
    private ProfessionArea professionArea;

    @OneToOne
    @JoinColumn(name = "FK_CITY_ID", referencedColumnName = "ID", insertable = false, updatable = false)
    private City city;


    public City getCity() {
        return city;
    }

    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public SexType getSex() {
        return sex;
    }

    public void setSex(SexType sex) {
        this.sex = sex;
    }

    public Integer getFkCityId() {
        return fkCityId;
    }

    public void setFkCityId(Integer fkCityId) {
        this.fkCityId = fkCityId;
    }

    public Integer getFkRegionId() {
        return fkRegionId;
    }

    public void setFkRegionId(Integer fkRegionId) {
        this.fkRegionId = fkRegionId;
    }

    public Boolean getMove() {
        return move;
    }

    public void setMove(Boolean move) {
        this.move = move;
    }

    public CitizenType getCitizenship() {
        return citizenship;
    }

    public void setCitizenship(CitizenType citizenship) {
        this.citizenship = citizenship;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public Boolean getStartInLife() {
        return startInLife;
    }

    public void setStartInLife(Boolean startInLife) {
        this.startInLife = startInLife;
    }

    public String getSalary() {
        return salary;
    }

    public void setSalary(String salary) {
        this.salary = salary;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getAccountUUID() {
        return accountUUID;
    }

    public void setAccountUUID(String accountUUID) {
        this.accountUUID = accountUUID;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public List<ResumeFile> getResumeFiles() {
        return resumeFiles;
    }

    public void setResumeFiles(List<ResumeFile> resumeFiles) {
        this.resumeFiles = resumeFiles;
        if (resumeFiles != null) {
            for (ResumeFile resumeFile : resumeFiles) {
                resumeFile.setResume(this);
            }
        }
    }

    public ProfessionArea getProfessionArea() {
        return professionArea;
    }

    public String getFkProfAreaUuid() {
        return fkProfAreaUuid;
    }

    public void setFkProfAreaUuid(String fkProfAreaUuid) {
        this.fkProfAreaUuid = fkProfAreaUuid;
    }
}
